$(document).ready(function(){
	var config = {
		extraPlugins : 'tableresize',
		skin:'office2003',
		toolbar : 'MyToolbar',
		toolbar_MyToolbar :
			[
				{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
				{ name: 'editing', items : [ 'Find','Replace', 'Scayt' ] },
				{ name: 'links', items : [ 'Link','Unlink','Anchor' ] },

				{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','TextColor','BGColor','-','RemoveFormat' ] },
				{ name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
				
				{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock' ] },
				{ name: 'tools', items : [ 'Source','Maximize','ShowBlocks','Templates' ] },
				
				{ name: 'styles', items : [ 'Format','Font','FontSize' ] }
				
			]
	};
	
	//bewerk click event
	$(".editArticle").click(function(){
		//replace articleDiv
		var article_id = $(this).attr('tag');
		var article = $(this).parents(".article");
		var page = UrlSegment(2);
		$.ajax({

			url: base_url + 'edit/getEditor/'+page+'/'+article_id,
			success: function(data) {
				article.html(data);
				setEditor(".editArea");
			}
		});

	});
	
	
	function setEditor(selector)
	{
		editor = $(selector).ckeditor(config);
		CKFinder.setupCKEditor( editor, '../' ) 
	}
});